import { defHttp } from '@/utils/http/axios';
import { ID, IDS } from '@/api/base';
import { AuthVO, AuthForm, AuthQuery } from './model';

/**
 * 查询授权用户列表
 * @param params
 * @returns
 */
export function authList(params?: AuthQuery) {
  return defHttp.get<AuthVO[]>({ url: '/ma/manage/auth', params });
}

/**
 * 导出授权用户列表
 * @param params
 * @returns
 */
export function authExport(params?: AuthQuery) {
  return defHttp.post<Blob>(
    { url: '/auth/auth/export', params, responseType: 'blob' },
    { isTransformResponse: false },
  );
}

/**
 * 查询授权用户详细
 * @param id id
 * @returns
 */
export function authInfo(id: ID) {
  return defHttp.get<AuthVO>({ url: '/auth/auth/' + id });
}

/**
 * 新增授权用户
 * @param data
 * @returns
 */
export function authAdd(data: AuthForm) {
  return defHttp.postWithMsg<void>({ url: '/auth/auth', data });
}

/**
 * 更新授权用户
 * @param data
 * @returns
 */
export function authUpdate(data: AuthForm) {
  return defHttp.putWithMsg<void>({ url: '/auth/auth', data });
}

/**
 * 删除授权用户
 * @param id id
 * @returns
 */
export function authRemove(id: ID | IDS) {
  return defHttp.postWithMsg<void>({ url: '/auth/auth/' + id });
}

/**
 * 提交代码
 * @param id id
 * @returns
 */
export function submitAudit(id: ID | IDS) {
  return defHttp.postWithMsg<void>({ url: '/ma/manage/submitAudit/' + id });
}
/**
 * 上传代码
 * @param id id
 * @returns
 */
export function uploadCode(id: ID | IDS) {
  return defHttp.postWithMsg<void>({ url: '/ma/manage/uploadCode/' + id });
}
/**
 * 查询审核状态
 * @param id id
 * @returns
 */
export function queryStatus(id: ID | IDS) {
  return defHttp.postWithMsg<void>({ url: '/ma/manage/queryStatus/' + id });
}
/**
 * 回退上一个版本
 * @param id id
 * @returns
 */
export function revertCodeRelease(id: ID | IDS) {
  return defHttp.postWithMsg<void>({ url: '/ma/manage/revertCodeRelease/' + id });
}
/**
 * 发布
 * @param id id
 * @returns
 */
export function release(id: ID | IDS) {
  return defHttp.postWithMsg<void>({ url: '/ma/manage/release/' + id });
}
